Skip to content

feat(agent): Telegram hooks + --continue resume + ralph-hook binary#51

Merged
gHashTag merged 1 commit into
mainfrom
ralph/w1/telegram-hooks
Mar 9, 2026
Merged

feat(agent): Telegram hooks + --continue resume + ralph-hook binary#51
gHashTag merged 1 commit into
mainfrom
ralph/w1/telegram-hooks

Conversation

@gHashTag
Copy link
Copy Markdown
Owner

@gHashTag gHashTag commented Mar 9, 2026

Summary

  • telegram.zig — fire-and-forget Telegram sender (send/sendDraft/sendFmt) using oracle_watchdog HTTP pattern
  • ralph_hook.zig — standalone Zig binary called by Claude Code hooks; reads stdin JSON, formats and sends to Telegram
  • claude_runner.zig--continue flag for native session resume (replaces HANDOVER.md), mcp__telegram__SEND_MESSAGE in allowedTools
  • agent_loop.zig — WAKE/SLEEP Telegram reporting; hooks handle all per-tool reporting
  • hooks.json — PostToolUse, PostToolUseFailure, Stop events call ralph-hook binary
  • .mcp.json@iqai/mcp-telegram MCP server for Claude self-reporting

Architecture

ralph-agent (Zig daemon)
├── WAKE → telegram.send("WAKE #N")
├── Spawn claude -p <prompt> --continue --max-turns N
│   ├── PostToolUse hook → ralph-hook → TG: "tool done"
│   ├── PostToolUseFailure hook → ralph-hook → TG: "tool FAILED"
│   ├── Stop hook → ralph-hook → TG: "Session finished"
│   └── Claude MCP → mcp__telegram__SEND_MESSAGE (self-report)
└── SLEEP → telegram.send("Sleeping Ns...")

364 insertions, 38 deletions across 8 files (2 new, 6 modified)

Test plan

  • zig build — both ralph-agent (4.5MB) and ralph-hook (4.3MB) compile
  • echo '{"hook_event_name":"PostToolUse","tool_name":"Bash"}' | ralph-hook — sends to Telegram API
  • ralph-agent --single-shot — shows v2.0.0, Telegram enabled/disabled
  • Run with real TELEGRAM_BOT_TOKEN + TELEGRAM_CHAT_ID to verify end-to-end reporting

🤖 Generated with Claude Code

- telegram.zig: fire-and-forget Telegram sender (send/sendDraft/sendFmt)
- ralph_hook.zig: standalone binary for Claude Code hooks → Telegram
- claude_runner.zig: --continue support, mcp__telegram__SEND_MESSAGE
- agent_loop.zig: WAKE/SLEEP Telegram reporting, --continue after wake #1
- main.zig: TELEGRAM_BOT_TOKEN/CHAT_ID env vars, v2.0.0
- hooks.json: PostToolUse/PostToolUseFailure/Stop → ralph-hook
- .mcp.json: @iqai/mcp-telegram for Claude self-reporting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@gHashTag gHashTag merged commit c75e0b0 into main Mar 9, 2026
7 of 9 checks passed
@gHashTag gHashTag deleted the ralph/w1/telegram-hooks branch March 9, 2026 13:21
gHashTag added a commit that referenced this pull request Mar 18, 2026
feat(agent): Telegram hooks + --continue resume + ralph-hook binary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant